﻿using QD.LopPlat.Models;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.Migrations;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QD.LopPlat.Repository
{
    public class PlatDbContext : DbContext
    {
        private static PlatDbContext platDbContextInstance;
        public static PlatDbContext PlatDbContextInstance
        {
            get
            {
                if (platDbContextInstance == null)
                    platDbContextInstance = new PlatDbContext();

                return platDbContextInstance;
            }
            set
            {
                platDbContextInstance = value;
            }
        }

        private PlatDbContext()
            : base(DataBaseRepository.SqlConnectionStr(false))
        {
            Database.SetInitializer<PlatDbContext>(null);
        }

        public DbSet<FormID> FormID { get; set; }
        public DbSet<Public_ReportSet> Public_ReportSet { get; set; }
        public DbSet<Public_Report> Public_Report { get; set; }
        public DbSet<FormUIDataGridConfiguration> FormUIDataGridConfiguration { get; set; }
        public DbSet<FormUIDateGridBasicConfiguration> FormUIDateGridBasicConfiguration { get; set; }
        public DbSet<FormUIListConfiguration> FormUIListConfiguration { get; set; }
        public DbSet<Sys_DropDownList> Sys_DropDownList { get; set; }
        public DbSet<Sys_DropDownListData> Sys_DropDownListData { get; set; }
        public DbSet<FormJs> FormJs { get; set; }
        public DbSet<FormUIHeadConfiguration> FormUIHeadConfiguration { get; set; }
        public DbSet<FormGridDataBaseConfiguration> FormGridDataBaseConfiguration { get; set; }
        public DbSet<FormRelevance> FormRelevance { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();//移除复数表名的契约

            base.OnModelCreating(modelBuilder);
        }
    }
}
